{% extends './layout.html' %} {% block title %} {{ title }} {% endblock %}{% block crumbs %}
<a href="/">首页</a>
<a href="/story">小说管理</a>
<a href="/story">首页</a>
<a><cite>采集网站管理</cite></a>
{% endblock %}{% block body %}
<div class="layout_cont">
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">章节标题</label>
			<div class="layui-input-block">
				<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">章节内容</label>
			<div class="layui-input-block">
				<textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>
{% endblock %} {% block scripts %}
<script type="text/javascript">
	console.log(({}+{}).length);
	layui.use(['form', 'layedit'], function() {
		var $ = layui.jquery;
		var form = layui.form;
		var layedit = layui.layedit;

		//创建一个编辑器
		var layeditor = layedit.build('LAY_demo_editor', {
			tool: ['strong', 'underline', 'del', 'addhr', '|', 'left', 'center', 'right'],
			height: 500
		});

		//监听提交
		form.on('submit(add)', function(data) {
			$.post('create', {
				title: data.field.title,
				content: layedit.getContent(layeditor)
			}).then(data => {
				if(data.code == 200){
					window.location.href = '/chapter/{{bookno}}';
				}
			})
			return false;
		});
	});
</script>
{% endblock %}